﻿var exec = require("child_process").exec;


function start(response) {
  console.log("Request handler 'start' was called.");
  
  var content = "empty";
/*

  exec("find /",
    { timeout: 10000, maxBuffer: 20000*1024 },
    function (error, stdout, stderr) {
      response.writeHead(200, {"Content-Type": "text/plain"});
      response.write(stdout);
      response.end();
    });
 */
 
  exec("ls -lah", function (error, stdout, stderr) {
  /*
        function sleep(milliSeconds) {
            var startTime = new Date().getTime();
            while (new Date().getTime() < startTime + milliSeconds);
        }

	   sleep(10000);
*/
  
       response.writeHead(200, {"Content-Type": "text/plain"});
       response.write("hello start");
       response.end();
  });

  
   //return content;

}

function upload(response) {
  console.log("Request handler 'upload' was called.");
  

  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello Upload");
  response.end();

}

function test() {
  console.log("Request handler 'test' was called.");
  return "Hello test";
}

exports.start = start;
exports.upload = upload;
exports.test = test;